﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cs746
{
    class TAData
    {
        private List<Node> _objects;
        private List<Edge> _edges;

        public TAData()
        {
            _objects = new List<Node>();
            _edges = new List<Edge>();
        }

        public bool AddObject(string name, ObjectType type) 
        {
            var obj = new Node(name, type);
            if (_objects.Contains(obj)) return false;
            _objects.Add(obj);
            return true;
        }

        public bool AddEdge(string startpoint, string endpoint, EdgeType type) 
        {
            var edge = new Edge(startpoint, endpoint, type);
            if (_edges.Contains(edge)) return false;
            _edges.Add(edge);
            return true;
        }

        public List<Node> Objects { get { return new List<Node>(_objects); } }
        public List<Edge> Edges { get { return new List<Edge>(_edges); } }
    }

    struct Node 
    {
        private readonly string _name;
        private readonly ObjectType _type;

        public string Name { get { return _name; } }
        public ObjectType Type { get { return _type; } }

        public Node(string name, ObjectType type)
        {
            _name = name; _type = type;
        }

        public override string ToString()
        {
            return string.Format("{0} - {1}", _name, _type);
        }
    }

    struct Edge 
    {
        private readonly string _startPoint;
        private readonly string _endPoint;
        private readonly EdgeType _type;

        public string StartPoint { get { return _startPoint; } }
        public string EndPoint { get { return _endPoint; } }
        public EdgeType Type { get { return _type; } }

        public Edge(string startpoint, string endpoint, EdgeType type)
        {
            _startPoint = startpoint;
            _endPoint = endpoint;
            _type = type;
        }

        public override string ToString()
        {
            return string.Format("{0} - {1} - {2}", _startPoint, _type, _endPoint);
        }
    }

    enum ObjectType 
    {
        Interface,
        Class,
        Function, // put here all other "kinds" of functions
        VirtualFunction,
        StaticFunction,
        Ctor,
        MethodReference
    }

    enum EdgeType
    {
        Call,
        VirtualCall,
        RecursiveCall,
        Contains,
        CtorCall
    }
}
